﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace DeliveryService
{
    public class BLSchool
    {

        public List<MSchool> GetSchools()
        {
            using (DeliveryDBDataContext db = new DeliveryDBDataContext())
            {
                return db.Schools
                         .Select(s => new MSchool { SchoolId = s.school_Id, SchoolName = s.school_name, Address = s.school_address })
                         .ToList();
            }
        }

        public List<MSchool> GetSchools(string name)
        {
            using (DeliveryDBDataContext db = new DeliveryDBDataContext())
            {
                return db.Schools.Where(s => s.school_name.Contains(name))
                    .Select(s => new MSchool { SchoolId = s.school_Id, SchoolName = s.school_name, Address = s.school_address }).ToList();
            }
        }

    }
}